//
//  GCMQualityRequst.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/8/10.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMQualityRequst.h"
#import "GCMHTModel.h"

@implementation GCMQualityRequst

+ (NSURLSessionDataTask *)postDataWithGLC:(NSString *)glc Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"glc"] = glc;
    
    return [[CZHAppNetAPIClient sharedClient] POST:QUALITYJIBIE_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSMutableArray *ReciveListArray = [[NSMutableArray alloc]init];
        NSMutableArray *reciveListArray = [[NSMutableArray alloc]init];
        reciveListArray = [dict objectForKey:@"data"];
        for (NSDictionary *dict1 in reciveListArray) {
            NSDictionary *dic = [[NSDictionary alloc]initWithDictionary:dict1];
            [ReciveListArray addObject:dic];
        }
        
        if (success) {
            
            success(ReciveListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
}

+ (NSURLSessionDataTask *)postQGZRHListDataWithaId:(NSString *)aid WithhtId:(NSString *)htId WithJibie:(NSString *)jibie WithType:(NSString *)type WithDate:(NSString *)date Success:(void (^) (id obj , NSError *))success{
    
    NSMutableDictionary *parameters= [[NSMutableDictionary alloc]init];
    
    parameters[@"a_id"] = aid;
    parameters[@"ht_id"] = htId;
    parameters[@"yiji_id"] = jibie;
    parameters[@"type"] = type;
    parameters[@"date"] = date;
    
    
    return [[CZHAppNetAPIClient sharedClient] POST:QUALISTQJXMGL_URL parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"++1====+  %@",dict);
        
        NSMutableArray *ReciveListArray = [[NSMutableArray alloc]init];
        NSMutableArray *reciveListArray = [[NSMutableArray alloc]init];
        reciveListArray = [dict objectForKey:@"data"];
        NSLog(@"++1====+  %@",reciveListArray);
        for (NSDictionary *dict1 in reciveListArray) {
            [ReciveListArray addObject:[CZHChangeNullString getValueFromDictionary:dict1]];
            
            NSLog(@"每条数据 %@",ReciveListArray);
            
        }
        if (success) {
            success(ReciveListArray,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
}


+ (NSURLSessionDataTask *)postDataWithParmerts:(NSDictionary *)parmerts WithUrl:(NSString *)url Success:(void (^) (id obj , NSError *))success{
    
    return [[CZHAppNetAPIClient sharedClient] POST:url parameters:parmerts success:^(NSURLSessionDataTask *task, id responseObject) {

        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
//        NSLog(@"*打分1%@",dict);
        
        if (success) {
            success(dict,nil);
        }
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"++2+  %@",error);
        if (success) {
            success(nil, error);
        }
    }];
    
    
}

@end
